function resolveIp() {
    var zkAddress =$("#zkAddress").val();
    var interfaceName =$("#interfaceName").val();
    var url ="/dubbo/resolveIp";
    $.ajax({
        url:url,
        method:"get",
        data:{
            zkAddress:zkAddress,
            interfaceName:interfaceName
        },
        success:function (responseMessage) {
            if(responseMessage.success){
                var ipList =responseMessage.obj;
                var str;
                ipList.forEach(function (v) {
                    str+="<option value='"+v+"'>"+v+"</option>"
                })
                $("#ip").html(str);
                $("#ip").selectpicker("refresh");
            }else {
                alert(responseMessage.msg);
            }
        }
    })
}
function resolveMethod() {
    var ip =$("#ip").val();
    var interfaceName =$("#interfaceName").val();
    var url ="/dubbo/resolveMethod";
    $.ajax({
        url:url,
        method:"get",
        data:{
            ip:ip,
            interfaceName:interfaceName
        },
        success:function (responseMessage) {
            if(responseMessage.success){
                //首先我们拿到map
                var obj =responseMessage.obj;
                var methodList =obj.methodList;
                var str;
                methodList.forEach(function (v) {
                    str+="<option value='"+v+"'>"+v+"</option>"
                });
                $("#interfaceMethod").html(str);
                $("#interfaceMethod").selectpicker("refresh");

               var param= obj.param;
               if(""!=param && "undefined" !=typeof (param)) {
                   var o = $.parseJSON(param);
                   paramJsonEditor.set(o);
               }
            }else {
                alert(responseMessage.msg);
            }
        }
    })
}
function methodParam() {
    var ip =$("#ip").val();
    var interfaceName =$("#interfaceName").val();
    var interfaceMethod =$("#interfaceMethod").val();
    var url="/dubbo/methodParam";
    $.ajax({
        url:url,
        method:"post",
        data:{
            ip:ip,
            interfaceName:interfaceName,
            interfaceMethod:interfaceMethod
        },
        success:function (responseMessage) {
            if(responseMessage.success){
                var paramList =responseMessage.obj;
                var o = $.parseJSON(paramList);
                paramJsonEditor.set(o);
            }
        }
    })
}

function componentMethodParam() {
    var ip =$("#ip").val();
    var interfaceName =$("#interfaceName").val();
    var interfaceMethod =$("#interfaceMethod").val();
    var url="/dubbo/methodParam";
    $.ajax({
        url:url,
        method:"post",
        data:{
            ip:ip,
            interfaceName:interfaceName,
            interfaceMethod:interfaceMethod
        },
        success:function (responseMessage) {
            if(responseMessage.success){
                var paramList =responseMessage.obj;
                // var o = $.parseJSON(paramList);
                $("#param").val(paramList);
            }
        }
    })
}
function componentResolveMethod() {
    var ip =$("#ip").val();
    var interfaceName =$("#interfaceName").val();
    var url ="/dubbo/resolveMethod";
    $.ajax({
        url:url,
        method:"post",
        data:{
            ip:ip,
            interfaceName:interfaceName
        },
        success:function (responseMessage) {
            if(responseMessage.success){
                //首先我们拿到map
                var obj =responseMessage.obj;
                var methodList =obj.methodList;
                var str;
                methodList.forEach(function (v) {
                    str+="<option value='"+v+"'>"+v+"</option>"
                });
                $("#interfaceMethod").html(str);
                $("#interfaceMethod").selectpicker("refresh");
                var param= obj.param;
                $("#param").val(param);
            }else {
                alert(responseMessage.msg);
            }
        }
    })
}

function invoke() {
    var ip =$("#ip").val();
    var interfaceName =$("#interfaceName").val();
    var interfaceMethod =$("#interfaceMethod").val();
    var param =JSON.stringify(paramJsonEditor.get());
    var encoding =$("#encoding").val();
    var timeout=$("#timeout").val();
    var url ="/dubbo/invoke";
    $.ajax({
        url:url,
        method:"post",
        data:{
            ip:ip,
            interfaceName:interfaceName,
            interfaceMethod:interfaceMethod,
            param:param,
            encoding:encoding,
            timeout:timeout,
            interfaceType:"dubbo"
        },
        success:function (responseMessage) {
            try {
                var o = $.parseJSON(responseMessage);
                resultJsonEditor.set(o);
            }catch (e) {
                resultJsonEditor.set(responseMessage);
            }
        }
    })
}

function invokeForTestCase() {
    var param =JSON.stringify(paramJsonEditor.get());
    var url ="/dubbo/invokeForTestCase";
    $.ajax({
        url:url,
        method:"post",
        data:{
            param:param
        },
        success:function (responseMessage) {
            try {
                var o = $.parseJSON(responseMessage);
                resultJsonEditor.set(o);
            }catch (e) {
                resultJsonEditor.set(responseMessage);
            }
        }
    })
}